﻿<%@ Page Title="" Language="C#" MasterPageFile="/Common/Master.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentForm" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHtml" runat="Server">
    <div class="easyui-layout tableEdit" data-options="fit:true,border:false">
        <div data-options="region:'center',border:false" id="validation" class="validationEngineContainer">
            <div class="z_wrap">
                <ul class="info">
                 <%--   <li>
                        <em class='l_name'>工作流程ID：</em>
                        <div class='r_con1'>
                            <input id='WorkFlowID' name='WorkFlowID' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>--%>
                    <li>
                        <em class='l_name'>步骤：</em>
                        <div class='r_con1'>
                            <input id='StepIndex' name='StepIndex' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>上一步（如果两个节点 **,**）：</em>
                        <div class='r_con1'>
                            <input id='PStepIndex' name='PStepIndex' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>条件（简单的 0 , 1 区分）：</em>
                        <div class='r_con1'>
                            <input id='Requirement' name='Requirement' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>流程名称：</em>
                        <div class='r_con1'>
                            <input id='Name' name='Name' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>部门还是人负责处理（0 人 1 部门）：</em>
                        <div class='r_con1'>
                            <input id='OrgOrPerson' name='OrgOrPerson' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                    <li>
                        <em class='l_name'>备注：</em>
                        <div class='r_con1'>
                            <input id='Description' name='Description' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>
                 <%--   <li>
                        <em class='l_name'>创建时间：</em>
                        <div id='AddTime' class='r_con1'>自动</div>
                    </li>
                    <li>
                        <em class='l_name'>组织机构ID：</em>
                        <div class='r_con1'>
                            <input id='OrgID' name='OrgID' type='text' class='validate[required]' data-prompt-position='bottomRight' /></div>
                    </li>--%>
                </ul>
            </div>
        </div>
        <div data-options="region:'south'" style="height: 35px; border-bottom: 0px; border-left: 0px; border-right: 0px;" class="edit_bottom">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="buttonOk">确 定</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="$.layerClose(false);">取 消</a>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            jQuery('#validation').validationEngine();

            $("#buttonOk").click(function () {
                InsertOrUpdate();
            });
            if ($.getUrlParamer("guid") != "") {
                DataBind();
            }
        });

        function DataBind() {
            $.InvokeAjax({
                url: "Api/V1/System_WorkFlowDetailed/GetWorkFlowDetailed",
                data: { ID: $.getUrlParamer("guid") },
                callBack: function (data) {
                    var obj = $.StrToJson(data).Results;

                    $.SetValue("ID", obj.ID);
                    $.SetValue("WorkFlowID", obj.WorkFlowID);
                    $.SetValue("StepIndex", obj.StepIndex);
                    $.SetValue("PStepIndex", obj.PStepIndex);
                    $.SetValue("Requirement", obj.Requirement);
                    $.SetValue("Name", obj.Name);
                    $.SetValue("OrgOrPerson", obj.OrgOrPerson);
                    $.SetValue("Description", obj.Description);
                    $.SetValue("AddTime", $.DateFormat(obj.AddTime, 'yyyy-MM-dd HH:mm:ss'));
                    $.SetValue("OrgID", obj.OrgID);

                }
            });
        }

        function InsertOrUpdate() {
            if (!$('#validation').validationEngine('validate')) { return false; }
            var url = $.getUrlParamer("guid") != "" ? "Api/V1/System_WorkFlowDetailed/UpdateWorkFlowDetailed" : "Api/V1/System_WorkFlowDetailed/AddWorkFlowDetailed";

            var obj = { ID: $.getUrlParamer("guid") };
            obj.WorkFlowID = $.getUrlParamer("WorkFlowID");
            obj.StepIndex = $.GetValue("StepIndex");
            obj.PStepIndex = $.GetValue("PStepIndex");
            obj.Requirement = $.GetValue("Requirement");
            obj.Name = $.GetValue("Name");
            obj.OrgOrPerson = $.GetValue("OrgOrPerson");
            obj.Description = $.GetValue("Description");
            obj.AddTime = $.JsonDateFy($.GetValue("AddTime") == "自动" ? $.GetDateTime() : $.GetValue("AddTime"));
            obj.OrgID = $.GetValue("OrgID");


            $.InvokeAjax({
                url: url,
                data: obj,
                callBack: function (data) {
                    $.layerClose(true);
                }
            });
        }
    </script>
</asp:Content>
